<?php
/**
* alltosun.com 退出登录 logout.php
* ============================================================================
* 版权所有 (C) 2009-2014 北京互动阳光科技有限公司，并保留所有权利。
* 网站地址: http://www.alltosun.com
* ----------------------------------------------------------------------------
* 许可声明: 这是一个开源程序，未经许可不得将本软件的整体或任何部分用于商业用途及再发布。
* ============================================================================
* $Author: 吴松键 (wusj@alltosun.com) $
* $Date: 2014-9-2 上午10:17:29 $
* $Id$
*/

class Action
{
    /**
     * 退出登录
     */
    public function __call($action = '', $param = array())
    {
        $user_id = user_helper::get_user_id();
        // if (empty($user_id)) {
        //     return array('您还未登录。', 'error', AnUrl('user/login'));
        // }

        user_helper::remember_me_expire();
        $callback = user_helper::get_jump_url();
        if(strpos($callback, BBS_URL) === 0){
            $callback = BBS_URL;
        } else {
            $callback = AnUrl('');
        }

        if(in_array(user_helper::get_login_way(), array('lenovo', 'lenovoSSO'))) {
            $openapi = Config::get('openapi');
            $callbackUrl = AnUrl('user/logout/uc_logout');
            $check_info = 'https://passport.lenovo.com/wauthen2/gateway?lenovoid.action=uilogout&lenovoid.realm='.$openapi['lenovo'][0].'&lenovoid.cb='.$callbackUrl.'&lenovoid.ctx='.urlencode($callback);
            Response::redirect($check_info);
        } else {
            echo user_helper::uc_logout($callback);
        }

    }

    public function uc_logout() {
        $ctx = Request::Get('lenovoid_ctx');
        if($ctx) {
            $callbackUrl = $ctx;
        } else {
            $callbackUrl = AnUrl('');
        }

        echo user_helper::uc_logout($callbackUrl);
    }

    public function test()
    {
        return '这是提示信息';
    }
}
?>